package com.example.adminframework.response;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.ArrayList;
import java.util.List;

/**
 * 分页数据
 */
@ApiModel("分页返回类")
public class PageContent<T> {
    @ApiModelProperty("数据内容")
    private List<T> data;
    @ApiModelProperty("数据总长度")
    private Integer total;

    public static <T> PageContent<T> getPage(List<T> data, Integer total) {
        return new PageContent<>(data, total);
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    public PageContent() {
        this.data = new ArrayList<>();
        this.total = 0;
    }

    public PageContent(List<T> data, Integer total) {
        this.data = data;
        this.total = total;
    }

    @Override
    public String toString() {
        return "PageContent{" +
                "data=" + data +
                ", total=" + total +
                '}';
    }
}
